namespace :news_groups do

  desc "将原系统导入的news中,10月15号之前发布的news全部设置为已采用,15号之后的设置为已经送审"
  task :old_news => :environment do
    all_news = News.all
    admin_group = Group.where(:name => '管理员').first
    all_news.each do |news|
      p "=================old==news===#{news.id}==================="
      if news.pubtime.blank? || (news.pubtime <= '2014/10/15'.to_time)
        NewsGroup.create(:news_id => news.id,:group_id => admin_group.id,:check => 1)
        news.update_attributes(:aprroved_count => 1)
      else
        NewsGroup.create(:news_id => news.id,:group_id => admin_group.id)
      end

    end
  end
 desc "change news editby is wangjing to yifeng"
  task :data_change => :environment do
str1="update news set editby='亦枫' where editby='wangjing'"
str2="update news set editby='党委宣传部' where editby is null"
ActiveRecord::Base.connection.execute(str1);
ActiveRecord::Base.connection.execute(str2);
  end

desc "delete_category_23"
  task :delete_category_23 => :environment do
    str1 = " delete from news where category_id=23;"
    ActiveRecord::Base.connection.execute(str1);
  end

end